home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / ScriptX / Documentation / Code Examples from Docs / compguid / doctemp / simpldoc.sx < prev   
Encoding:
Text File  |  1996-05-21  |  1.6 KB  |  64 lines  |  [TEXT/ttxt]

  1. --<<<
  2.  
  3. -- Create the boundary for the pages
  4. pageRect := new Rect x2:300 y2:360
  5.  
  6. -- Create a line to appear across the top of each page.
  7. theLine := new twoDshape boundary:(new line x1:0 x2:300 y1:0 y2:0)
  8. theLine.stroke := new brush color:redcolor
  9.  
  10. -- Position the line near the top of the page
  11. theLine.y := 50
  12.  
  13. -- Create a text box to hold the page number appear on each page.
  14. textBounds := new Rect x2:50 y2:20
  15. pageNumberBox := new TextPresenter boundary:textBounds \
  16.     target:("" as Text) 
  17. pageNumberElement := new PageElement \
  18.     presenter:pageNumberBox target:(e -> getParentData e Page)
  19.  
  20. -- Center the page number element near the bottom of the page
  21. pageNumberElement.x := 250
  22. pageNumberElement.y := 30
  23.  
  24. -- Create a page layer and make its outline be blue
  25. layer1 := new PageLayer boundary:pageRect 
  26. layer1.stroke := new brush color:bluecolor
  27.  
  28.  
  29. -- append the line and the page number box to the page layer
  30. append layer1 pageNumberElement
  31. append layer1 theLine
  32.  
  33. -- Create a document and append two pages to it
  34. theDocument := new Document 
  35.  
  36. page1 := new Page boundary:pageRect \
  37.     frame:layer1 target:("Page 1" as text)
  38.  
  39. page2 := new Page boundary:pageRect \
  40.     frame:layer1 target:("Page 2" as text)
  41.  
  42. append theDocument page1
  43. append theDocument page2
  44.  
  45. -- Create a window that is slightly bigger than the first
  46. -- page in the document.
  47.  
  48. w := new window 
  49. w.fill := whitebrush
  50. w.height := page1.boundary.height + 50
  51. w.width := page1.boundary.width + 50
  52.  
  53. show w
  54.  
  55. -- Append the document to the window.
  56. -- Center the document in the window.
  57. append w theDocument
  58. theDocument.x := 25
  59. theDocument.y := 25
  60.  
  61. -- Open the second page
  62. goto theDocument 2
  63. -->>>
  64.